package com.service;

import static com.def.GenericDef.EVT_WO_CHANGE;
import static com.def.GenericDef.E_READ_NOT_FOUND;
import static com.def.GenericDef.E_RET_BOX;
import static com.def.GenericDef.E_RET_PRD_INFO;
import static com.def.GenericDef.E_RET_WO;
import static com.def.GenericDef.E_XPWOCHG_DIFF_BOX_ADMIN_FLG_WHEN_CHANGE_WO;
import static com.def.GenericDef.E_XPWOCHG_INVALID_INPUT;
import static com.def.GenericDef.PROC_COMPLETE;
import static com.def.GenericDef.PROC_EMPTY;
import static com.def.GenericDef.PROC_SHIP;
import static com.def.GenericDef.RETURN_CODE_OK;
import static com.def.GenericDef.RETURN_CODE_SET_ERROR;
import static com.def.GenericDef.RETURN_CODE_UNKNOWN;
import static com.def.GenericDef.RETURN_MESG_OK;
import static com.def.GenericDef.TRX_OUT;
import static com.def.GenericDef.T_XPWOCHG;
import static com.def.GenericDef._NORMAL;
import static com.def.GenericDef._YES;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.LockMode;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import com.dao.IBisDataDao;
import com.dao.IBisMdlDefDao;
import com.dao.IBisOpeDao;
import com.dao.IBisPathDao;
import com.dao.IRetBoxDao;
import com.dao.IRetPrdInfoDao;
import com.dao.IRetWODao;
import com.icim.service.ICIMBaseService;
import com.model.Bis_data;
import com.model.Bis_mdl_def;
import com.model.Bis_ope;
import com.model.Bis_opeId;
import com.model.Bis_path;
import com.model.Ret_box;
import com.model.Ret_prd_info;
import com.model.Ret_wo;
import com.rtnBean.NotFoundRtnBeen;
import com.rtnBean.SimpleRtnBeen;
import com.tx.xpwochg.XpwochgI;
import com.tx.xpwochg.XpwochgIA_prd2l;
import com.tx.xpwochg.XpwochgIA_prd2r;
import com.tx.xpwochg.XpwochgO;
import com.util.MqOpe;
import com.util.Util;

@Scope("prototype")
@Service("XpwochgService")
public class XpwochgService extends ICIMBaseService{
	private static Logger logger = Logger.getLogger(XpwochgService.class);
	private static String TX_NAME = T_XPWOCHG;

	private XpwochgI inTrx;
	private XpwochgO outTrx;
	private MqOpe mqOpe;

	@Autowired
	private IBisMdlDefDao bisMdlDefDao;
	@Autowired
	private IRetBoxDao retBoxDao;
	@Autowired
	private IRetPrdInfoDao retPrdInfoDao;
	@Autowired
	private IRetWODao retWODao;
	@Autowired
	private IBisOpeDao bisOpeDao;
	@Autowired
	private IBisPathDao bisPathDao;
	@Autowired
	private IBisDataDao bisDataDao;
	
	
	
	private String gszMsgBuf = "";

	private Timestamp gEvtTimestamp;
	private Double gEvtTimeD;

	private Ret_wo gLeft_wo = new Ret_wo();
	private Ret_wo gRight_wo = new Ret_wo();
	private Ret_box gLeft_box = new Ret_box();
	private Ret_box gRight_box = new Ret_box();

	public String subMainProc(String strInMsg) {
		Session session = retPrdInfoDao.getCrSession();
		long rtnCode = _NORMAL;
		String outMsg = null;

		gszMsgBuf = "";
		gEvtTimestamp = Util.getCurrentTimestamp();
		gEvtTimeD = Util.getDoubleTime();
		inTrx = new XpwochgI();
		outTrx = new XpwochgO();
		outTrx.setTrx_id(TX_NAME);
		outTrx.setRtn_code(String.valueOf(RETURN_CODE_SET_ERROR));
		outTrx.setType_id(TRX_OUT);

		mqOpe = new MqOpe();

		try {
			inTrx = (XpwochgI) mqOpe.inStr2Obj(strInMsg, inTrx);

			rtnCode = subMainProc2(inTrx.getAction_flg().toCharArray()[0]);
			if (rtnCode != _NORMAL) {
				TransactionAspectSupport.currentTransactionStatus()
						.setRollbackOnly();
				outTrx.setRtn_code(String.valueOf(rtnCode));
				outTrx.setRtn_mesg(gszMsgBuf);
			} else {
				outTrx.setRtn_code(String.valueOf(RETURN_CODE_OK));
				outTrx.setRtn_mesg(RETURN_MESG_OK);
				session.flush();
			}
		} catch (Exception ex) {
			TransactionAspectSupport.currentTransactionStatus()
					.setRollbackOnly();
			outTrx.setRtn_mesg(ex.toString());
			outTrx.setRtn_code(RETURN_CODE_UNKNOWN);
			logger.error(Util.stackTraceToString(ex));
		} finally {
			outMsg = mqOpe.obj2Str(outTrx);
			return outMsg;
		}
	}

	/**
	 * Real action type
	 * 
	 * @param actionType
	 * @return
	 */
	private long subMainProc2(char actionType) {
		SimpleRtnBeen rtnBeen = new SimpleRtnBeen(_NORMAL);
		long lRc = _NORMAL;
		switch (actionType) {
		case 'C': {
			rtnBeen = boxWoFunc();
			if (rtnBeen.getlRc() != _NORMAL) {
				gszMsgBuf = rtnBeen.getMsgBuf();
				return rtnBeen.getlRc();
			}
			break;
		}

		default: {
			gszMsgBuf = "Invalide type input: [" + actionType + "]";
			return E_XPWOCHG_INVALID_INPUT;
		}
		}

		return lRc;
	}

	/**
	 * 交换箱
	 * 
	 * @return
	 */
	private SimpleRtnBeen boxWoFunc() {
		long lStat = 0;
		SimpleRtnBeen rtnBeen = new SimpleRtnBeen(_NORMAL);
		long lRc = _NORMAL;
		int leftAQty = 0, leftBQty = 0,  leftCQty = 0, rightAQty = 0, rightBQty = 0, rightCQty = 0;
		String ope_id = "", ope_ver = "", dps_ope_id = "", dps_mdl_cate = "";

		// Get wo
		gLeft_wo = retWODao.getWithLock(inTrx.getLeft_wo_id(), LockMode.UPGRADE);
		if (null == gLeft_wo) {
			return new SimpleRtnBeen(E_RET_WO + E_READ_NOT_FOUND,
					new NotFoundRtnBeen(inTrx.getLeft_wo_id(), Ret_wo.class).toString());
		}

		gRight_wo = retWODao.getWithLock(inTrx.getRight_wo_id(),
				LockMode.UPGRADE);
		if (null == gRight_wo) {
			return new SimpleRtnBeen(E_RET_WO + E_READ_NOT_FOUND,
					new NotFoundRtnBeen(inTrx.getRight_wo_id(), Ret_wo.class).toString());
		}
		
		if ( !gLeft_wo.getCus_id_fk().equals(gRight_wo.getCus_id_fk())) {
			return new SimpleRtnBeen(
				E_XPWOCHG_DIFF_BOX_ADMIN_FLG_WHEN_CHANGE_WO,
				"两个工单对应的客户不同，不能转，请确认！" + "工单["
						+ gLeft_wo.getWo_id() + "]，客户为["
						+ gLeft_wo.getCus_id_fk() + "]，工单["
						+ gRight_wo.getWo_id() + "]，客户为["
						+ gRight_wo.getCus_id_fk() + "]");			
		}
		
		if ( !gLeft_wo.getMdl_id_fk().equals(gRight_wo.getMdl_id_fk()) ) {
			Bis_mdl_def bismdl_l = bisMdlDefDao.get(gLeft_wo.getMdl_id_fk());
			Bis_mdl_def bismdl_r = bisMdlDefDao.get(gLeft_wo.getMdl_id_fk());
			if (!bismdl_l.getLayot_id_fk().equals(bismdl_r.getLayot_id_fk())) {
				return new SimpleRtnBeen(
					E_XPWOCHG_DIFF_BOX_ADMIN_FLG_WHEN_CHANGE_WO,
					"两个工单对应的版式不同，不能转，请确认！" + "工单["
							+ gLeft_wo.getWo_id() + "]，版式为["
							+ bismdl_l.getLayot_id_fk() + "]，工单["
							+ gRight_wo.getWo_id() + "]，版式为["
							+ bismdl_r.getLayot_id_fk() + "]");			
			}
			if ( !gLeft_wo.getPath_id_fk().equals(gRight_wo.getPath_id_fk()) ) {
				return new SimpleRtnBeen(
					E_XPWOCHG_DIFF_BOX_ADMIN_FLG_WHEN_CHANGE_WO,
					"两个工单对应的工艺路线不同，不能转，请确认！" + "工单["
							+ gLeft_wo.getWo_id() + "]，工艺路线为["
							+ gLeft_wo.getPath_id_fk() + "]，工单["
							+ gRight_wo.getWo_id() + "]，工艺路线为["
							+ gRight_wo.getPath_id_fk() + "]");	
			}
		}

		// Get box
		if (_YES.equals(inTrx.getHas_box_id())) {
			gLeft_box = retBoxDao.getWithLock(inTrx.getLeft_box_id(),
					LockMode.UPGRADE);
			if (null == gLeft_box) {
				return new SimpleRtnBeen(E_RET_BOX + E_READ_NOT_FOUND,
						new NotFoundRtnBeen(inTrx.getLeft_box_id() , Ret_box.class).toString());
			}
			if (gLeft_box.getBox_stat().equals(PROC_COMPLETE)){
				lStat = 1;
			}else if ((gLeft_box.getBox_stat().equals(PROC_SHIP)) && (gLeft_box.getBnk_flg().equals("1"))){
				lStat = 2;
			}else if ((gLeft_box.getBox_stat().equals(PROC_SHIP)) && (gLeft_box.getBnk_flg().equals("2"))){
				lStat = 3;
			}
			gRight_box = retBoxDao.getWithLock(inTrx.getRight_box_id(),
					LockMode.UPGRADE);
			if (null == gRight_box) {
				return new SimpleRtnBeen(E_RET_BOX + E_READ_NOT_FOUND,
						new NotFoundRtnBeen(inTrx.getRight_box_id() , Ret_box.class).toString());
			}
			//Check PRD_ADMIN_FLG
			if(gLeft_box.getBnk_flg().equals("2") || gRight_box.getBnk_flg().equals("2")){
				if(null != gLeft_box.getPrd_admin_flg() && null != gRight_box.getPrd_admin_flg()){
					if( (!PROC_EMPTY.equals(gRight_box.getBox_stat())) && (!PROC_EMPTY.equals(gLeft_box.getBox_stat()))   
							&&	(!gLeft_box.getPrd_admin_flg().substring(0,1).equals(gRight_box.getPrd_admin_flg().substring(0,1))) ){
							return new SimpleRtnBeen(
									E_XPWOCHG_DIFF_BOX_ADMIN_FLG_WHEN_CHANGE_WO,
									"两个箱子的半成品可出货状态不同，请确认！" + "左侧箱号["
											+ gLeft_box.getBox_id() + "]，半成品可出货状态["
											+ gLeft_box.getPrd_admin_flg().substring(0,1) + "]，右侧箱号["
											+ gRight_box.getBox_id() + "]，半成品可出货状态["
											+ gRight_box.getPrd_admin_flg().substring(0,1) + "]");
						}
					
				}			
			}
			
			if (gLeft_box.getBox_stat().equals(PROC_SHIP) && gRight_box.getBox_stat().equals(PROC_SHIP)) {
				if ( !gLeft_box.getDest_shop().equals(gRight_box.getDest_shop()) ) {
					return new SimpleRtnBeen(
							E_XPWOCHG_DIFF_BOX_ADMIN_FLG_WHEN_CHANGE_WO,
							"两个箱子的厂别态不同，请确认！" + "左侧箱号["
									+ gLeft_box.getBox_id() + "]，仓别["
									+ gLeft_box.getDest_shop() + "]，右侧箱号["
									+ gRight_box.getBox_id() + "]，仓别["
									+ gRight_box.getDest_shop() + "]");
				}
			}
						
		}

		// Fetch prd
		// <-
		if (inTrx.getTo_left_cnt() > 0) {
			List<Ret_prd_info> leftRetPrdInfoList = new ArrayList<Ret_prd_info>();
			for (XpwochgIA_prd2l prdInfo : inTrx.getIary_2left()) {
				Ret_prd_info prd = retPrdInfoDao.getWithLock(
						prdInfo.getPrd_seq_id(), LockMode.UPGRADE);
				if (null == prd) {
					return new SimpleRtnBeen(E_RET_PRD_INFO + E_READ_NOT_FOUND,
							new NotFoundRtnBeen(prdInfo.getPrd_seq_id(),
									Ret_prd_info.class).toString());
				}
				
			
				if (prd.getPrd_stat().equals("WAIT")){
					if (!prd.getNx_path_id_fk().equals(gLeft_wo.getPath_id_fk())){
						return new SimpleRtnBeen(
								E_XPWOCHG_DIFF_BOX_ADMIN_FLG_WHEN_CHANGE_WO,
								"非主工艺路线产品不能转工单！" );					
					}
					ope_id = prd.getCr_ope_id_fk();
					ope_ver = prd.getCr_ope_ver_fk();											
				}else if (prd.getPrd_stat().equals("INPR")){
					if (!prd.getCr_path_id_fk().equals(gLeft_wo.getPath_id_fk())){
						return new SimpleRtnBeen(
								E_XPWOCHG_DIFF_BOX_ADMIN_FLG_WHEN_CHANGE_WO,
								"非主工艺路线产品不能转工单！" );					
					}
					ope_id = prd.getCr_ope_id_fk();
					ope_ver = prd.getCr_ope_ver_fk();						
				}
			
				if (prd.getRsn_dept5() != null && prd.getRsn_dept5().equals("Y")){
					leftAQty += 1;
				}
				if ( prd.getRsn_cate5() != null && prd.getRsn_cate5().equals("Y") ){
					leftBQty += 1;
				}
				if ( prd.getRsn_code5() != null && prd.getRsn_code5().equals("Y") ){
					leftCQty += 1;
				}

				
				prd.setWo_id_fk(prdInfo.getWo_id_fk());// gLeft_wo.getWo_id()
				prd.setSo_id_fk(gLeft_wo.getSo_id());
				prd.setMdl_id_fk(gLeft_wo.getMdl_id_fk());
				prd.setMdl_cate_fk(gLeft_wo.getMdl_cate_fk());
				prd.setPrd_thickness(gLeft_wo.getTo_thickness());
				prd.setMtrl_prod_id_fk(gLeft_wo.getMtrl_prod_id_fk());
				if (!Util.isSpaceCheck(prdInfo.getBox_id_fk())) {
					prd.setBox_id_fk(prdInfo.getBox_id_fk());
					leftRetPrdInfoList.addAll(retPrdInfoDao.getShtListInfo(inTrx.getLeft_box_id()));
				}else{
					leftRetPrdInfoList.add(prd);
				}

				prd.setEvt_cate(EVT_WO_CHANGE);
				prd.setEvt_time_d(gEvtTimeD);
				prd.setEvt_timestamp(gEvtTimestamp);
				prd.setEvt_usr(inTrx.getEvt_user());
				retPrdInfoDao.update(prd);
			}
			lRc = CheckQrsOverFlgMixProc(leftRetPrdInfoList);
			if(lRc !=_NORMAL){
				return new SimpleRtnBeen(lRc, "跨制程产品不能混转");
			}
		}

		// ->
		if (inTrx.getTo_right_cnt() > 0) {
			List<Ret_prd_info> rightRetPrdInfoList = new ArrayList<Ret_prd_info>();
			for (XpwochgIA_prd2r prdInfo : inTrx.getIary_2right()) {
				Ret_prd_info prd = retPrdInfoDao.getWithLock(
						prdInfo.getPrd_seq_id(), LockMode.UPGRADE);
				if (null == prd) {
					return new SimpleRtnBeen(E_RET_PRD_INFO + E_READ_NOT_FOUND,
							new NotFoundRtnBeen(prdInfo.getPrd_seq_id(),
									Ret_prd_info.class).toString());
				}


				
				if (prd.getPrd_stat().equals("WAIT")){
					if (!prd.getNx_path_id_fk().equals(gRight_wo.getPath_id_fk())){
						return new SimpleRtnBeen(
								E_XPWOCHG_DIFF_BOX_ADMIN_FLG_WHEN_CHANGE_WO,
								"非主工艺路线产品不能转工单！" );					
					}
					
					ope_id = prd.getCr_ope_id_fk();
					ope_ver = prd.getCr_ope_ver_fk();											
				}else if (prd.getPrd_stat().equals("INPR")){
					if (!prd.getCr_path_id_fk().equals(gRight_wo.getPath_id_fk())){
						return new SimpleRtnBeen(
								E_XPWOCHG_DIFF_BOX_ADMIN_FLG_WHEN_CHANGE_WO,
								"非主工艺路线产品不能转工单！" );					
					}
					ope_id = prd.getCr_ope_id_fk();
					ope_ver = prd.getCr_ope_ver_fk();						
				}
				if (prd.getRsn_dept5() != null && prd.getRsn_dept5().equals("Y")){
					rightAQty += 1;
				}
				if ( prd.getRsn_cate5() != null && prd.getRsn_cate5().equals("Y") ){
					rightBQty += 1;
				}
				if ( prd.getRsn_code5() != null && prd.getRsn_code5().equals("Y") ){
					rightCQty += 1;
				}
				
				prd.setWo_id_fk(prdInfo.getWo_id_fk());
				prd.setSo_id_fk(gRight_wo.getSo_id());
				prd.setMdl_id_fk(gRight_wo.getMdl_id_fk());
				prd.setMdl_cate_fk(gRight_wo.getMdl_cate_fk());
				prd.setPrd_thickness(gRight_wo.getTo_thickness());
				prd.setMtrl_prod_id_fk(gRight_wo.getMtrl_prod_id_fk());
				if (!Util.isSpaceCheck(prdInfo.getBox_id_fk())) {
					prd.setBox_id_fk(prdInfo.getBox_id_fk());
					rightRetPrdInfoList.addAll(retPrdInfoDao.getShtListInfo(inTrx.getRight_box_id()));
				}else{
					rightRetPrdInfoList.add(prd);
				}

				prd.setEvt_cate(EVT_WO_CHANGE);
				prd.setEvt_time_d(gEvtTimeD);
				prd.setEvt_timestamp(gEvtTimestamp);
				prd.setEvt_usr(inTrx.getEvt_user());
				retPrdInfoDao.update(prd);
			}
			lRc = CheckQrsOverFlgMixProc(rightRetPrdInfoList);
			if(lRc !=_NORMAL){
				return new SimpleRtnBeen(lRc, "跨制程产品不能混转");
			}
		}

		// Update box
		if (_YES.equals(inTrx.getHas_box_id())) {
			gLeft_box.setEvt_cate(EVT_WO_CHANGE);
			gLeft_box.setEvt_time_d(gEvtTimeD);
			gLeft_box.setEvt_timestamp(gEvtTimestamp);
			gLeft_box.setEvt_usr(inTrx.getEvt_user());
			rtnBeen = retBoxDao.configBoxInfo(gLeft_box);
			if (rtnBeen.getlRc() != _NORMAL) {
				return rtnBeen;
			}

			gLeft_box = (Ret_box) rtnBeen.getObj();
			retBoxDao.update(gLeft_box);

			gRight_box.setEvt_cate(EVT_WO_CHANGE);
			gRight_box.setEvt_time_d(gEvtTimeD);
			gRight_box.setEvt_timestamp(gEvtTimestamp);
			gRight_box.setEvt_usr(inTrx.getEvt_user());
 
			rtnBeen = retBoxDao.configBoxInfo(gRight_box);
			if (rtnBeen.getlRc() != _NORMAL) {
				return rtnBeen;
			}

			gRight_box = (Ret_box) rtnBeen.getObj();
			retBoxDao.update(gRight_box);
		}

		// Update wo
		gLeft_wo.setEvt_usr(inTrx.getEvt_user());
		gLeft_wo.setEvt_timestamp(gEvtTimestamp);
		gLeft_wo.setPln_prd_qty(gLeft_wo.getPln_prd_qty()
				+ inTrx.getTo_left_cnt() - inTrx.getTo_right_cnt());
		gLeft_wo.setRl_prd_qty(gLeft_wo.getRl_prd_qty()
				+ inTrx.getTo_left_cnt() - inTrx.getTo_right_cnt());
		if(null == gLeft_wo.getAct_stb_timestamp()&& null != gRight_wo.getAct_stb_timestamp()){
			gLeft_wo.setAct_stb_timestamp(gRight_wo.getAct_stb_timestamp());
		}
		if (lStat == 1){
			gLeft_wo.setComp_prd_qty(gLeft_wo.getComp_prd_qty()	+ inTrx.getTo_left_cnt() - inTrx.getTo_right_cnt());
		}else if (lStat == 2){
			gLeft_wo.setWh_in_prd_qty(gLeft_wo.getWh_in_prd_qty() + inTrx.getTo_left_cnt() - inTrx.getTo_right_cnt());
		}else if (lStat == 3){
			gLeft_wo.setWip_wh_in_prd_qty(gLeft_wo.getWip_wh_in_prd_qty() + inTrx.getTo_left_cnt() - inTrx.getTo_right_cnt());
		}
		retWODao.update(gLeft_wo);
		
        String pathSql = "From Bis_path where path_id_fk = '"+gLeft_wo.getPath_id_fk()+"' and NX_OPE_NO = '"+ope_id+"'"; 
        List<Bis_path>  bisPathList = bisPathDao.find(pathSql);
        if (!bisPathList.isEmpty()) {
        	dps_ope_id = bisPathList.get(0).getCr_ope_id_fk();
    		Bis_opeId opeId = new Bis_opeId();
    		opeId.setOpe_id(bisPathList.get(0).getCr_ope_id_fk());
    		opeId.setOpe_ver(bisPathList.get(0).getCr_ope_ver_fk());        	
    		Bis_ope shtOpe = bisOpeDao.get(opeId);
    		String hql = "FROM Bis_data where data_cate = 'PRST' and data_id = '" + shtOpe.getProc_id() + "'" ;
    		List<Bis_data> dataList = new ArrayList<Bis_data>();
    		dataList = bisDataDao.find(hql);
    		if (!dataList.isEmpty()) {
    			dps_mdl_cate = dataList.get(0).getExt_4();
    		}
    	}
		


		gRight_wo.setEvt_usr(inTrx.getEvt_user());
		gRight_wo.setEvt_timestamp(gEvtTimestamp);
		gRight_wo.setPln_prd_qty(gRight_wo.getPln_prd_qty()
				+ inTrx.getTo_right_cnt() - inTrx.getTo_left_cnt());
        gRight_wo.setRl_prd_qty(gRight_wo.getRl_prd_qty()
				+ inTrx.getTo_right_cnt() - inTrx.getTo_left_cnt());
		if(null == gRight_wo.getAct_stb_timestamp()&& null != gLeft_wo.getAct_stb_timestamp()){
			gRight_wo.setAct_stb_timestamp(gLeft_wo.getAct_stb_timestamp());
		}
		if (lStat == 1){
	        gRight_wo.setComp_prd_qty(gRight_wo.getComp_prd_qty() + inTrx.getTo_right_cnt() - inTrx.getTo_left_cnt());			
		}else if (lStat == 2){
	        gRight_wo.setWh_in_prd_qty(gRight_wo.getWh_in_prd_qty()	+ inTrx.getTo_right_cnt() - inTrx.getTo_left_cnt());			
		}else if (lStat == 3){
	        gRight_wo.setWip_wh_in_prd_qty(gRight_wo.getWip_wh_in_prd_qty()	+ inTrx.getTo_right_cnt() - inTrx.getTo_left_cnt());			
		}
		retWODao.update(gRight_wo);
		return rtnBeen;
	}
	private long CheckQrsOverFlgMixProc(List<Ret_prd_info> retPrdInfoList){
		String qrsOvrFlg1 ,qrsOvrFlg2;
		for (int i = 1; i < retPrdInfoList.size(); i++) {
			qrsOvrFlg1 = retPrdInfoList.get(0).getQrs_ovr_flg();
			qrsOvrFlg2 = retPrdInfoList.get(i).getQrs_ovr_flg();
			if(qrsOvrFlg2==null){
				qrsOvrFlg2 = "";
			}
			if(!qrsOvrFlg2.equals(qrsOvrFlg1)){
				gszMsgBuf = "跨制程段产品不能混装,错误";
				return 1;
			}
		}
		return _NORMAL;
	}

}
